package com.yang.design.structure.proxy.cglib;

import java.util.List;

public class Client {
    public static void main(String[] args) {
        //目标对象
        UserServiceImpl userService = new UserServiceImpl();
        System.out.println(userService.getClass());//class com.yang.design.structure.proxy.cglib.UserServiceImpl

        //代理对象，是目标类的子类，可以强转为目标类
        UserServiceImpl logProxy = (UserServiceImpl)new UserLogProxy(userService).getLogProxy();
        System.out.println(logProxy);//com.yang.design.structure.proxy.cglib.UserServiceImpl$$EnhancerByCGLIB$$33585d29@16b3fc9e

        //执行
        List<User> userList = logProxy.findUserList("张三", 18);
        System.out.println(userList);//[User(name=张三, age=18)]

    }
}
